<template>
	<view class="content">
		<view class="navbar">
			<view  class="navbaritem"   v-for="(item,index) of title" :key=index @click="navto(index)">
				<text :class="currentIndex==index?'botline':''">{{item.title}}</text>
			</view>	
		</view>
		<!-- 算力区域start -->
		<view class="suanli" v-if="currentIndex==0">
			<view class="box">
				我的总算力：{{totalsuanli}} TB
			</view>
			<view class="row" v-for="(item,index) of suanlilist" :key="index">
				<text>{{item.tnum}} TB</text>
				<text>{{item.create_at|formatDate}}</text>
			</view>
		</view>
		<!-- 算力区域end -->
		<!-- 收益区域start -->
		<view class="shouyi" v-if="currentIndex==1">
			<view class="box">
				我的总收益：{{totalshouyi}} TB
			</view>
			<view class="shouyirow" v-for="(item,index) of shouyilist" :key="index">
				<view class="row1">
					<text>时间</text>
					<text class="row1_r">收益(FIL)</text>
				</view>
				<view class="row2">
					<text>{{item.create_at}}</text>
					<text class="row1_r fcolor">{{item.total_profit}}</text>
				</view>
				<view class="row1">
					<text>待释放(FIL)</text>
					<text class="row1_r">已释放(FIL)</text>
				</view>
				<view class="row2">
					<text>{{item.wait_profit}}</text>
					<text class="row1_r">{{item.over_profit}}</text>
				</view>
				<view class="row1">
					<text>25%立即释放(FIL)</text>
					<text class="row1_r">已释放天数/总天数</text>
				</view>
				<view class="row2">
					<text>{{item.direct_profit}}</text>
					<text class="row1_r">{{item.release_day}}天</text>
				</view>
			</view>
		</view>
		<!-- 收益区域end -->
		<!-- 释放区域start -->
		<view class="shifang" v-if="currentIndex==2">
			<view class="box">
				我的总释放：{{totalshifang}} FIL
			</view>
			<view class="row" v-for="(item,index) of shifanglist" :key="index">
				<text>{{item.direct_profit}} + {{item.release_profit}} </text>
				<text>{{item.create_at}}</text>
			</view>
		</view>
		<!-- 释放区域end -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title:[
					{
						id:1,
						title:'算力明细'
					},
					{
						id:2,
						title:'收益明细'
					},
					{
						id:3,
						title:'释放明细'
					}
				],
				currentIndex:0,
				suanlilist:[],
				shouyilist:[],
				shifanglist:[],
				totalsuanli:0,
				totalshouyi:0,
				totalshifang:0,
			}
		},
		onLoad() {
			this.getinfo()
			
			
		},
		mounted() {
			let pages = getCurrentPages();
			let curPage = pages[pages.length-1];
			if(!curPage.options){
				this.getinfo()
			}else{
				
				this.getinfo()
				console.log(curPage.options.currentIndex)
				this.currentIndex=curPage.options.currentIndex
			}
		},
		methods: {
			navto(index){
				 this.currentIndex = index
			},
			getinfo(){
				
				var token =uni.getStorageSync('token')
				if(token==''||token==null){
					uni.reLaunch({
					    url:'../login/login'
					})
				}else{
					this.http({
					 	url:'/api/Page/tnumDetails',
					 	method:'POST',
						header:{
							'token':token
						},
					 	success:(res)=>{
							console.log(res)
							console.log('ssssss')
							this.suanlilist =res.data.result
							this.totalsuanli = res.data.count_tnum
						},
					 	error:()=>{
					 		uni.showToast({
					 			title:"请求异常"	
					 		})
					 	},	
					 })
					 this.http({
					  	url:'/api/Page/releaseDetails',
					  	method:'POST',
					 	header:{
					 		'token':token
					 	},
					  	success:(res)=>{
					 		console.log(res)
							console.log('fffffffff')
					 		this.shifanglist =res.data.result
							this.totalshifang = res.data.total
					 	},
					  	error:()=>{
					  		uni.showToast({
					  			title:"请求异常"	
					  		})
					  	},	
					  })
					this.http({
					 	url:'/api/Page/profitDetails',
					 	method:'POST',
						header:{
							'token':token
						},
					 	success:(res)=>{
							console.log(res)
							console.log('yyyyyyyyyyyy')
							this.shouyilist =res.data.result
							this.totalshouyi = res.data.total
						},
					 	error:()=>{
					 		uni.showToast({
					 			title:"请求异常"	
					 		})
					 	},	
					 })
				}
			},
		}
	}
</script>

<style lang="scss">
.content{
	padding-bottom: 50rpx;
	font-family: PingFang SC;
	font-weight: 400;
	color: #000000;
	.fcolor{
		color:#0072FF
	}
	.navbar{
		width: 690rpx;
		height: 98rpx;
		background: #FFFFFF;
		box-shadow: 0px 0px 5px 0px rgba(43, 43, 43, 0.18);
		border-radius: 5px;
		margin: 20rpx auto;
		display: flex;
		justify-content: space-around;
		
		.navbaritem{	
			height: 98rpx;
			font-size: 30rpx;
			font-weight: bold;
			color: #2B2B2B;
			line-height: 98rpx;
		}
	}
	.botline{
		color: #007AFF;
		padding-bottom: 5px;
		border-bottom:  4px solid #007AFF;
	}
	.box{
		width: 690rpx;
		height: 128rpx;
		background: #0072FF;
		border-radius: 10rpx;
		margin: 40rpx auto 50rpx auto;
		font-size: 30rpx;
		font-weight: bold;
		color: #FFFFFF;
		line-height: 128rpx;
		text-indent: 1.5rem;
	}
	.row{
		width: 617rpx;
		height: 80rpx;
		background: #FFFFFF;
		box-shadow: 0px 0px 3px 0px rgba(43, 43, 43, 0.18);
		border-radius: 5px;
		margin: 0 auto 10rpx auto;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0 31rpx 0 42rpx;
		font-size: 30rpx;
		font-family: PingFang SC;
		color: #0072FF;
	}
	.shouyirow{
		width: 690rpx;
		height: 350rpx;
		background: #FFFFFF;
		box-shadow: 0px 0px 3px 0px rgba(43, 43, 43, 0.18);
		border-radius: 5px;
		margin: 0 auto 40rpx auto;
		.row1_r{
			text-align: right;
		}
		.row1{
			width: 608rpx;
			margin: 0 auto;
			padding-top: 36rpx;
			display: flex;
			justify-content: space-between;
			font-size: 26rpx;
			font-weight: 500;
		}
		.row2{
			width: 608rpx;
			margin:  7rpx auto 0 auto;
			display: flex;
			justify-content: space-between;
			font-size: 26rpx;
			font-weight: 500;
		}
	}
}
</style>
